<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../vue.js"></script>
</head>

<body>

  <div id="app">
    {{username}}
    <custom-input :username.sync="username"></custom-input>
  </div>


  <script>

    Vue.component('custom-input', {
      template: `
      <input type="text"  @change="$emit('update:username',$event.target.value)" />
      `
    })



    var vm = new Vue({
      el: "#app",
      data: {
        username: ''
      },
      methods: {
        // handleChange(val) {
        //   this.username = val;
        // }
      }
    })

  </script>

</body>

</html>